package com.kasinf.sample.captcha;

import com.kasinf.framework.captcha.dto.Captcha;
import com.kasinf.framework.captcha.dto.Verification;
import com.kasinf.framework.captcha.processor.CaptchaRendererFactory;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @Author : Kaiser
 * @Date: 2025/5/12  15:13
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("captcha")
public class CaptchaController {

    private final CaptchaRendererFactory captchaRendererFactory;

    @GetMapping("get")
    public Captcha getCaptcha(String key, String category) {
         return captchaRendererFactory.getCaptcha(key, category);
    }

    @PostMapping("verify")
    public boolean verifyCaptcha(@RequestBody Verification verification) {
        return captchaRendererFactory.verify(verification);
    }
}
